-
-
Notifications
You must be signed in to change notification settings - Fork 13
Draft: migrate more Eloquent Casts #266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@albertcht Can you look into this? |
|
Hi @adhikjoshi, thanks for your pull request! I will look into this PR by this weekend. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds database model casting support by introducing new casting classes and updating the Castable interface to support additional return types. The changes extend the framework's ability to handle JSON data and create custom attribute accessors/mutators for Eloquent models.
- Extends the
Castableinterface to supportCastsAttributesas a return type - Adds JSON encoding/decoding utility class with customizable encoders/decoders
- Introduces new cast classes for collections and array objects
- Adds
Attributeclass for defining custom accessors and mutators
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/foundation/src/Http/Contracts/Castable.php | Updates interface to support CastsAttributes return type from Hyperf contract |
| src/core/src/Database/Eloquent/Casts/Json.php | Adds JSON utility class with customizable encoding/decoding support |
| src/core/src/Database/Eloquent/Casts/Attribute.php | Introduces attribute accessor/mutator class with caching support |
| src/core/src/Database/Eloquent/Casts/AsCollection.php | Implements castable for collection types with optional mapping |
| src/core/src/Database/Eloquent/Casts/AsArrayObject.php | Implements castable for ArrayObject with JSON serialization |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * Get the name of the caster class to use when casting from / to this cast target. | ||
| */ | ||
| public static function castUsing(array $arguments = []): CastInputs|string; | ||
| public static function castUsing(array $arguments = []): CastInputs|CastsAttributes|string; |
Copilot
AI
Nov 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CastInputs interface is referenced in the return type but not imported. Add use Hypervel\Foundation\Http\Contracts\CastInputs; at the top of the file to properly resolve this type.
|
Hi @adhikjoshi , there are I think you may try to submit this PR to Hyperf framework that Hypervel can benefit from it as well. |
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Good idea, adding PR there as well, |
|
I have fixed suggested changes, do review and feel free to merge it. |
|
Hi @adhikjoshi , if this PR can be merged in Hyperf framework, and Hypervel can use these casters as well. So I intend to keep this PR open for a while. If Hyperf team rejected to merge your submitted PR then we can merge this one to Hypervel. |
Currently only one Eloquent Casts is added
AsDataObjectAdding remaining casts to make hypervel drop-in-replacement of Laravel
ArrayObjectAsArrayObjectAsCollectionAttributeJsonAsStringablehttps://github.com/laravel/framework/blob/12.x/src/Illuminate/Database/Eloquent/Casts/Attribute.php